package com.tour.controller;


import com.tour.config.ResponseWrapper;
import com.tour.service.impl.FollowServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lel
 * @since 2020-12-30
 */
@Api(tags = "关注和取消关注")
@RestController
@RequestMapping("/app/follow")
public class FollowController {
    @Autowired
    FollowServiceImpl followService;

    @ApiOperation("关注某个人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineId",value = "用户自己的id"),
            @ApiImplicitParam(name = "followId",value = "关注的人的id")
    })
    @PostMapping("/addFollow")
    public ResponseWrapper addFollow(@RequestParam(name = "mineId")Integer mineId,
                                     @RequestParam(name = "followId")Integer followId){
        ResponseWrapper wrapper = followService.addFollow(mineId,followId);
        return wrapper;
    }

    @ApiOperation("取消关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineId",value = "用户自己的id"),
            @ApiImplicitParam(name = "followId",value = "关注的人的id")
    })
    @DeleteMapping("/delFollow")
    public ResponseWrapper delFollow(@RequestParam(name = "mineId")Integer mineId,
                                     @RequestParam(name = "followId")Integer followId){
        ResponseWrapper wrapper = followService.delFollow(mineId,followId);
        return wrapper;
    }
    @ApiOperation("查看是否关注")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineId",value = "用户自己的id"),
            @ApiImplicitParam(name = "followId",value = "关注的人的id")
    })
    @GetMapping("/isFollow")
    public ResponseWrapper isFollow(@RequestParam(name = "mineId")Integer mineId,
                                     @RequestParam(name = "followId")Integer followId){
        ResponseWrapper wrapper = followService.isFollow(mineId,followId);
        return wrapper;
    }

    @ApiOperation("查询所有关注的人")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineId",value = "用户自己的id"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
            @ApiImplicitParam(name = "pageNum",value = "页码数",defaultValue = "1")
    })
    @GetMapping("/findMyFollow")
    public ResponseWrapper findMyFollow(@RequestParam(name = "mineId")Integer mineId,
                                        @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
                                        @RequestParam(name = "pageNum",defaultValue = "1")Integer pageNum){
        ResponseWrapper wrapper = followService.findMyFollow(mineId,pageNum,pageSize);
        return wrapper;
    }
    @ApiOperation("查询所有粉丝")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "mineId",value = "用户自己的id"),
            @ApiImplicitParam(name = "pageSize",value = "每页展示的数据条数",defaultValue = "10"),
            @ApiImplicitParam(name = "pageNum",value = "页码数",defaultValue = "1")
    })
    @GetMapping("/findFollowMe")
    public ResponseWrapper findFollowMe(@RequestParam(name = "mineId")Integer mineId,
                                        @RequestParam(name = "pageSize",defaultValue = "10")Integer pageSize,
                                        @RequestParam(name = "pageNum",defaultValue = "1")Integer pageNum){
        ResponseWrapper wrapper = followService.findFollowMe(mineId,pageNum,pageSize);
        return wrapper;
    }
}

